﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.MobileControls;

public partial class SelectionList_CustomPaginationExample : System.Web.UI.MobileControls.MobilePage
{
    private TeamStats[] _premierTable;
    protected void Page_Load(object sender, EventArgs e)
    {
        this.List1.LoadItems += new LoadItemsEventHandler(this.LoadTeams);
        _premierTable = new TeamStats[16];
        _premierTable[0] = new TeamStats("Dunes", "Pts:80");
        _premierTable[1] = new TeamStats("Phoenix", "Pts:70");
        _premierTable[2] = new TeamStats("Eagles", "Pts:69");
        _premierTable[3] = new TeamStats("Zodiac", "Pts:68");
        _premierTable[4] = new TeamStats("Arches", "Pts:66");
        _premierTable[5] = new TeamStats("Chows", "Pts:61");
        _premierTable[6] = new TeamStats("Creation", "Pts:57");
        _premierTable[7] = new TeamStats("Illusion", "Pts:54");
        _premierTable[8] = new TeamStats("Torpedo", "Pts:52");
        _premierTable[9] = new TeamStats("Generals", "Pts:52");
        _premierTable[10] = new TeamStats("Reaction", "Pts:51");
        _premierTable[11] = new TeamStats("Peanuts", "Pts:49");
        _premierTable[12] = new TeamStats("Caverns", "Pts:48");
        _premierTable[13] = new TeamStats("Eclipse", "Pts:42");
        _premierTable[14] = new TeamStats("Dragons", "Pts:42");
        _premierTable[15] = new TeamStats("Cosmos", "Pts:42");
        List1.ItemCount = _premierTable.Length;
    }
    private void LoadTeams(Object source, LoadItemsEventArgs args)
    {
        List1.Items.Clear();
        //  The LoadItemsEventArgs tells us which items and how many.
        for (int i = 0; i < args.ItemCount; i++)
        {
            // Get the relevant item from the array;
            // Create a MobileListItem.
            int intTablePosn = args.ItemIndex + i;
            MobileListItem lstItem = new MobileListItem(
                string.Format("{0} {1}", intTablePosn + 1,
                    _premierTable[intTablePosn].TeamName),
               _premierTable[intTablePosn].Stats);

            // Add the item to the Items collection of the List control.
            List1.Items.Add(lstItem);
        }
    }
}